package com.wenc.psi.vmd;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.MutableLiveData;

import com.wenc.psi.pojo.Sale;
import com.wenc.psi.pojo.SaleDetail;
import com.wenc.psi.rpstr.SaleOrderRepository;

import java.util.List;

public class SaleOrderViewModel extends AndroidViewModel {

    private SaleOrderRepository saleOrderRepository;

    public MutableLiveData<List<Sale>> getSaleLive() {
        return saleOrderRepository.getSaleLive();
    }

    public SaleOrderViewModel(@NonNull Application application) {
        super(application);
        saleOrderRepository = new SaleOrderRepository(application);
    }

    public void getAllSaleOrder() {
        saleOrderRepository.getAllSaleOrder();
    }

    public void insertSale(Sale... sales){
        saleOrderRepository.insertSale(sales);
    }

    public void insertSaleDetail(SaleDetail... saleDetails) {
        saleOrderRepository.insertSaleDetail(saleDetails);
    }

    public void inserSaleOrder(Sale sale, SaleDetail... saleDetails){
        saleOrderRepository.inserSaleOrder(sale ,saleDetails);
    }
}
